<?php
/**
 * Created by PhpStorm.
 * User: wenjoying@126.com
 * Date: 2018/5/31
 * Time: 10:16
 */

namespace App\Models;

class Attach extends BaseModel
{
    /**
     * @var string 表名
     */
    protected $table = 'attachs';

    /**
     * @var string 主键
     */
    protected $primaryKey = 'id';

    /**
     * 填充字段
     * @var array
     */
    protected $fillable = [
        'user_id',
        'username',
        'file_size',
        'status',
        'origin_name',
        'filename',
        'file_path',
        'file_md5',
        'suffix',
        'more',

    ];

    /**
     * @desc 隐藏字段
     */
    protected $hidden = [];

    /**
     * @desc 动态增加字段
     */
    protected $appends = [
        'attach_url'
    ];

    /**
     * @desc 查找字段
     */
    public $columns = [];

    /**
     * @desc 附件地址
     */
    public function getAttachUrlAttribute()
    {
        return config('app.url').'storage/'.$this->attributes['file_path'];
    }


}
